home *** CD-ROM | disk | FTP | other *** search
/ Toolkit for Nursing Excel…t End of Life Transition / Toolkit for Nursing Excellence at End of Life Transition.iso / StartTneel.hta < prev    next >
Text File  |  2001-10-31  |  14KB  |  435 lines

  1. <HTA:APPLICATION ICON=tneelne.ico
  2. APPLICATIONNAME = "tneel-ne"
  3. WINDOWSTATE = "maximize"
  4. BORDERSTYLE = "complex"
  5. SINGLEINSTANCE = "yes"
  6. NAVIGABLE = "yes">
  7.  
  8. <HEAD>
  9. <TITLE>TNEEL-NE</TITLE>
  10.  
  11. <SCRIPT LANGUAGE="javascript">
  12.  
  13. var newWindow
  14.  
  15. function displayResults(htmlTags) {
  16. // Displays the results of a search in a new window    
  17.      
  18.     var head = "<HTML><HEAD><TITLE>Search Results</TITLE></HEAD><BODY>"
  19.      var tail = "</BODY></HTML>"
  20.      newWindow = window.open("","searchResults",config='height=200, width=400, left=0, top=0, toolbar=no,scrollbars=yes,resizable=yes')         
  21.     newWindow.opener=window        
  22.     newWindow.document.open()
  23.      newWindow.document.writeln(head)
  24.      newWindow.document.writeln(htmlTags)    
  25.      newWindow.document.writeln(tail)
  26.      newWindow.document.close()    
  27.     newWindow.focus()        
  28. }
  29.  
  30. function ShowPage(pagename) {
  31.     var sourcepath    
  32.  
  33.     sourcepath = getsourceTneelPath()
  34.     
  35.     parent.frames(0).gotopage(sourcepath,pagename)
  36.  
  37. }
  38.  
  39. </SCRIPT>
  40.  
  41. <SCRIPT LANGUAGE="vbscript">
  42.  
  43. dim gDriveLetter
  44. gDriveLetter=""
  45. createShortcut()
  46.  
  47.  
  48. '************************************************************************************************
  49.  
  50. function MiniSearch(searchterm)
  51.  
  52. 'this function uses the file searchfiles.csv to search for html files containing searchterm
  53. 'searches content, activities, and case studies sections only
  54.  
  55.     Dim fso
  56.     dim isin
  57.     dim filestosearch
  58.     dim filestosearchtemp
  59.     dim filestosearchbuffer    
  60.     dim pagetosearch
  61.     dim pagebuffer
  62.     dim sourcepath
  63.     dim searchfilespath
  64.     dim temphtm
  65.     dim searchString
  66.     dim count
  67.     dim searchingmessage
  68.  
  69.     On Error Resume Next
  70.     
  71.     sourcepath = getsourceTneelPath()    
  72.     searchfilespath = sourcepath + "searchfiles.csv"    
  73.     Set searchingmessage = window.showModelessDialog(sourcepath + "search/dialog.htm","","dialogHeight: 80px; dialogWidth: 240px; center: Yes; help: No; resizable: No; status: No; scroll: No;")
  74.  
  75.     if left(searchterm,1)="/" then
  76.         searchterm=searchterm.source    'get source of regular expression
  77.     end if
  78.  
  79.     searchString=searchterm
  80.  
  81.     searchterm = Trim(LCase(searchterm))
  82.     document.frames.item(0).searchterm = searchterm    
  83.  
  84.     Set fso = CreateObject("Scripting.FileSystemObject")    
  85.     Set filestosearch = fso.OpenTextFile(searchfilespath)
  86.  
  87.     temphtm = "<a class='definitionbold'>Results of search for:  " + searchString + "</a><p>"
  88.     count=0
  89.  
  90.     Do While NOT filestosearch.AtEndOfStream
  91.  
  92.         filestosearchtemp = filestosearch.ReadLine
  93.         if inStr(filestosearchtemp,"cont.htm")>0 or inStr(filestosearchtemp,"act.htm")>0 or inStr(filestosearchtemp,"case.htm")>0 then    
  94.             filestosearchbuffer = Left(filestosearchtemp, InStr(filestosearchtemp, "@") - 1)
  95.             Set pagetosearch = fso.OpenTextFile(sourcepath & filestosearchbuffer)
  96.             pagebuffer = pagetosearch.ReadAll
  97.             pagebuffer = LCase(pagebuffer)
  98.             isin = InStr(pagebuffer, searchterm)    
  99.         
  100.             if (isin > 0) then
  101.                 filestosearchbuffer = Replace(filestosearchtemp,"@", "')"">")
  102.                 temphtm = temphtm + "   <a class='ixlink' href=""javascript:window.opener.parent.frames(0).gotopage('" & sourcepath & "', '" & filestosearchbuffer & "</a><br>"
  103.                 count=count+1                
  104.             end if
  105.             pagetosearch.Close
  106.         end if
  107.     Loop
  108.     
  109.     filestosearch.Close    
  110.     if count=0 then
  111.         temphtm=temphtm+"   No documents found."
  112.     end if
  113.     
  114.     displayResults(temphtm)    'Call function to show search results in a popup window
  115.     
  116.     searchingmessage.close()
  117.  
  118.     set fso=Nothing
  119.  
  120. end function
  121.  
  122. '************************************************************************************************
  123.  
  124. function SearchFiles(searchterm)
  125. 'this search function uses the file searchfiles.csv to search for html files containing searchterm
  126.  
  127.     Dim fso
  128.     dim isin
  129.     dim filestosearch
  130.     dim filestosearchtemp
  131.     dim filestosearchbuffer    
  132.     dim pagetosearch
  133.     dim pagebuffer
  134.     dim sourcepath
  135.     dim searchfilespath
  136.     dim temphtm
  137.     dim searchString
  138.     dim count
  139.     dim searchingmessage
  140.  
  141.     On Error Resume Next
  142.     
  143.     sourcepath = getsourceTneelPath()    
  144.     searchfilespath = sourcepath + "searchfiles.csv"    
  145.     Set searchingmessage = window.showModelessDialog(sourcepath + "search/dialog.htm","","dialogHeight: 80px; dialogWidth: 240px; center: Yes; help: No; resizable: No; status: No; scroll: No;")
  146.  
  147.     if left(searchterm,1)="/" then
  148.         searchterm=searchterm.source    'get source of regular expression
  149.     end if
  150.  
  151.     searchString=searchterm
  152.  
  153.     searchterm = Trim(LCase(searchterm))
  154.     document.frames.item(0).searchterm = searchterm    
  155.  
  156.     Set fso = CreateObject("Scripting.FileSystemObject")    
  157.     Set filestosearch = fso.OpenTextFile(searchfilespath)
  158.  
  159.     temphtm = "<a class='definitionbold'>Results of search for:  " + searchString + "</a><p>"
  160.     count=0
  161.     
  162.     Do While NOT filestosearch.AtEndOfStream
  163.  
  164.         filestosearchtemp = filestosearch.ReadLine
  165.         filestosearchbuffer = Left(filestosearchtemp, InStr(filestosearchtemp, "@") - 1)
  166.         Set pagetosearch = fso.OpenTextFile(sourcepath & filestosearchbuffer)
  167.         pagebuffer = pagetosearch.ReadAll
  168.         pagebuffer = LCase(pagebuffer)
  169.         isin = InStr(pagebuffer, searchterm)    
  170.         
  171.         if (isin > 0) then
  172.             filestosearchbuffer = Replace(filestosearchtemp,"@", "')"">")            
  173.             temphtm = temphtm + "   <a class='ixlink' href=""javascript:window.opener.parent.frames(0).gotopage('" & sourcepath & "', '" & filestosearchbuffer & "</a><br>"
  174.             count=count+1                
  175.         end if
  176.         pagetosearch.Close
  177.     Loop
  178.     
  179.     filestosearch.Close    
  180.     if count=0 then
  181.         temphtm=temphtm+"   No documents found."
  182.     end if
  183.     
  184.     displayResults(temphtm)    'Call function to show search results in a popup window
  185.     
  186.     searchingmessage.close()
  187.  
  188.     set fso=Nothing
  189. end function
  190.  
  191. '************************************************************************************************
  192.  
  193. function exithta()
  194.     window.open("inst_eva.htm")
  195.     Set WshShell = CreateObject("WScript.Shell")
  196.     WSHShell.RegWrite "HKCR\.mp3\", "mp3file"
  197. end function
  198.  
  199. '************************************************************************************************
  200.  
  201. function SaveFiles(pageName)
  202.  
  203. 'This function saves the files from each page to the user's selected drive
  204. 'pageName=#filename for saving single files, pagename="multifile" for saving multiple files
  205. 'multiple files are saved by copying all files except .htm files from the module source folder
  206.     
  207.     window.focus()
  208.     On Error Resume Next    
  209.     dim i, msg, strTemp, response
  210.     dim destDriveLetter
  211.     dim fileName1, folderName, fso, drv, fldr, fil, fileTemp    
  212.     dim destFolderName
  213.     dim destPathAndName
  214.     dim sourceFolderName
  215.     dim sourceTneelPath
  216.     dim sourcePathAndName
  217.     dim thisFolder
  218.     dim yesNoCopy
  219.     dim numFilesCopied    
  220.     dim sourcePathConstruction
  221.     dim destPathConstruction
  222.     dim LineRead
  223.     dim destPath()
  224.     dim sourcePath()
  225.     dim FileToBeSaved()
  226.     dim callingmodule
  227.     dim file1
  228.     dim file2    
  229.     dim SavingMessageWindow
  230.         
  231.     callingmodule = window.frames(1).document.frames(2).location
  232.     callingmodule=ucase(callingmodule)    
  233.     callingmodule = Right(callingmodule, Len(callingmodule) - inStrRev(callingmodule, "/"))        
  234.     if left(callingmodule, 1)="#" or right(callingmodule, 1)="#" then
  235.         callingmodule = replace(callingmodule, "#", "")
  236.       end if    
  237. ' get rid off #video or #audiocase
  238.     if instr(callingmodule, "#")>0 then
  239.         callingmodule = left(callingmodule, instr(callingmodule, "#")-1)
  240.     end if
  241.       if left(PageName, 1)="#" then 
  242.         PageName=replace(PageName, "#", "")
  243.       end if
  244.     savebutton = ucase(pagename)
  245.     sourceTneelPath = getsourceTneelPath() 'Getting the path for the csv file
  246.     if sourceTneelPath = "" then
  247.         msgbox "You need to put CD disk back to the CD-ROM drive if you run the program on CD disk.", vbokonly, "Tneel-NE"
  248.         exit function
  249.       end if
  250.  
  251.     ' Opening the file, savefiles.txt, read the infor and assigned to the three dyname array variables.
  252.  
  253.       set fso=CreateObject("Scripting.FileSystemObject")
  254.     fileNameAndPath=sourcetneelpath & "savefiles.txt"
  255.     set filename1=fso.opentextfile(filenameandpath)
  256.     i = 1
  257.     do while not filename1.AtEndOfStream 
  258.           LineRead = filename1.ReadLine    
  259.         Linefield=split(lineread, ",")
  260.         linefield(0)=ucase(linefield(0))
  261.         linefield(1)=ucase(linefield(1))
  262.         if linefield(0)=callingmodule and linefield(1)=savebutton then
  263.             redim preserve fileToBeSaved(i)
  264.             redim preserve sourcepath(i)
  265.             redim preserve destpath(i)
  266.             filetobesaved(i)=linefield(2)
  267.             sourcepath(i)=linefield(3)
  268.             destpath(i)=linefield(4)
  269.             i=i+1
  270.             end if
  271.     loop
  272.     NumOfFiles = i-1
  273.     filename.close
  274.  
  275. ' Checking if the root path user entered exists.  If not create one.
  276.     
  277.     if gDriveLetter ="" then
  278.         destDriveLetter = getDestDriveLetter()
  279.     else
  280.         destDriveLetter=gDriveLetter
  281.     End if
  282.  
  283. Set SavingMessageWindow = window.showModelessDialog("SavingIndicator.htm","2","dialogHeight: 80px; dialogWidth: 240px; center: Yes; help: No; resizable: No; status: No; scroll: No;")
  284.  
  285.     destPathConstruction=split(destDriveLetter, "\")    
  286.     destDr = destpathconstruction(0)
  287.     for i = 1 to ubound(destpathconstruction)
  288.         destDr = destDr & "\" & destPathConstruction(i)
  289.         if fso.FolderExists(destDr) = false then
  290.             fso.CreateFolder(destDr)
  291.         end if 
  292.     Next
  293.  
  294. ' Adding the UserLocation path to the root path that user selected.  Checking the folder
  295. '  or the file exists.  If it does, copy the file.  If not, create the path and then copy the file.
  296.  
  297.     for i = 1 to NumOfFiles
  298.         destpathconstruction2=split(destpath(i), "\")
  299.           destpath2 = destDr & "\"
  300.         
  301.     for j = 0 to ubound(destpathconstruction2)-1
  302.         destpath2 = destpath2 & destpathconstruction2(j)
  303.         if fso.FolderExists(destpath2)=false then
  304.             fso.CreateFolder(destpath2)
  305.         end if
  306.         destpath2=destpath2 & "\"            
  307.     next                        ' After this loop, destpath2 has the dest. path
  308. 'checking and/or copying files from sourcePath to destpath
  309.         SourcePathAndName=getSourceTneelPath & SourcePath(i) & filetobesaved(i)
  310.         destPathAndName = destpath2 & filetobesaved(i)    
  311.         set file1 = fso.getfile(destPathAndName)
  312.         if file1.name <> filetobesaved(i) then
  313.             fso.copyfile SourcePathAndName, destPathAndName
  314.             set file2 = fso.getfile(destPathAndName)
  315.             if not isnull(file2.name) then
  316.                 file2.attributes = 0
  317.             else
  318.                 msgbox "The file that you wanted to save has not been saved.  Please contact tech support for help.", vbOkonly+vbinformation, "Tneel-ne message"
  319.             end if
  320.         end if
  321. next
  322. SavingMessageWindow.close()
  323. msgbox "The file saving work has completed.", vbOKOnly+VBINFORMATION, "Tneel-ne Message"
  324. set fso=nothing
  325. end function
  326.  
  327. '************************************************************************************************
  328.  
  329. function getsourceTneelPath()
  330.  
  331.     On Error Resume Next
  332.     dim validDrive
  333.     validDrive = 0
  334.     validdrive=window.top.document.location
  335.       validdrive=replace(validdrive, "file:///", "")
  336.     validDrive = Left(validDrive, inStrRev(validDrive, "/"))
  337.     validDrive = replace(validDrive, "%20", " ")
  338.     validDrive = replace(validDrive, "%23", "#")
  339.     validDrive = replace(validDrive, "%25", "%")
  340.     validDrive = replace(validDrive, "%7b", "{")
  341.     validDrive = replace(validDrive, "%7d", "}")
  342.     validDrive = replace(validDrive, "%5e", "^")
  343.     validDrive = replace(validDrive, "%7e", "~")
  344.     validDrive = replace(validDrive, "%5b", "[")
  345.     validDrive = replace(validDrive, "%5d", "]")
  346.     validDrive = replace(validDrive, "%60", "'")
  347.     validDrive = replace(validDrive, "%26", "&")    
  348.     getsourceTneelPath = validDrive
  349. end function
  350.  
  351. '************************************************************************************************
  352.  
  353. function getDestDriveLetter()
  354.  
  355.     On Error Resume Next    
  356.     dim strTemp
  357.     dim showDriveLetterWindow
  358.  
  359.     if gDriveLetter = "" then 'if this is the first save during this run
  360.         gDriveLetter=showModalDialog("driveletter.htm","1","dialogWidth:450px; dialogHeight:240px")
  361.     END IF
  362.     getDestDriveLetter = gDriveLetter
  363. end function
  364.  
  365. '************************************************************************************************
  366.  
  367. function createShortcut()
  368. 'if it already exists it will be re-written 
  369.     on error resume next
  370.                  
  371.     dim sourceTneelPath
  372.     dim WshShell
  373.     dim oShellLink
  374.     dim DesktopPath
  375.     dim MyDocsPath
  376.     dim fso
  377.     dim file1
  378.     dim fileSource, fileDest
  379.                                   
  380.     sourceTneelPath = getsourceTneelPath()
  381.     if sourceTneelPath = "0" then
  382.         alert("Please insert the TNEEL CD into your CDROM drive.")
  383.         exit function
  384.     else
  385.         'alert("got sourceTneelPath, = " & sourceTneelPath)
  386.     end if                 
  387.                  
  388.     Set WshShell = CreateObject("WScript.Shell")
  389.     
  390.     ' make sure that mplayer2 is registered to play .mp3 files.
  391.                                    
  392.     tempvar = WSHShell.RegRead ("HKEY_USERS\.DEFAULT\Software\Microsoft\MediaPlayer\Setup\CreatedLinks\AppName")                                
  393.     
  394.     if tempvar = "" then
  395.         WSHShell.RegWrite "HKEY_USERS\.DEFAULT\Software\Microsoft\MediaPlayer\Setup\CreatedLinks\AppName", "C:\Program Files\Windows Media Player\mplayer2.exe"
  396.         tempvar = "C:\Program Files\Windows Media Player\mplayer2.exe"                                
  397.     end if
  398.     
  399.     WSHShell.RegWrite "HKCR\.mp3\", "mp3file"
  400.     WSHShell.RegWrite "HKCR\.mp3\Content Type\", "audio/mpeg"
  401.     WSHShell.RegWrite "HKCR\mp3file\shell\open\command\", """" + tempvar + """" + " /Open " + """" + "%L" + """"
  402.     WSHShell.RegWrite "HKCR\mp3file\shell\open\command\", """" + tempvar + """" + " /Play " + """" + "%L" + """"                       
  403.     
  404.     DesktopPath = WSHShell.SpecialFolders("Desktop")
  405.     Set oShellLink = WshShell.CreateShortcut(DesktopPath & "\tneel-ne.lnk")
  406.     oShellLink.TargetPath = sourceTneelPath & "StartTneel.hta"
  407.     
  408.     MyDocsPath = WSHShell.SpecialFolders("MyDocuments")
  409.     
  410.     if (MyDocsPath <> "") then    
  411.          fileSource = sourceTneelPath & "tneelne.ico"
  412.          fileDest = MyDocsPath & "\tneelne.ico"
  413.          set fso=CreateObject("Scripting.FileSystemObject")
  414.          fso.CopyFile fileSource, fileDest
  415.          oShellLink.IconLocation = fileDest
  416.     else
  417.             oShellLink.IconLocation = sourceTneelPath & "tneelne.ico"            
  418.     end if
  419.  
  420.     oShellLink.Save    
  421.  
  422. end function
  423.  
  424. </script>
  425.  
  426. </HEAD>
  427.  
  428. <frameset rows="1,*" cols="*" border="0" framespacing="0" frameborder="NO" onUnload="exithta()"> 
  429.   <frame src="browser_bar.htm" name="browser_bar" frameborder="NO" APPLICATION="yes" scrolling="no">
  430.     <FRAMESET  id="mainframe">
  431.         <FRAME  SRC="splash.html" ID="frameone" APPLICATION="yes">
  432.     </FRAMESET>
  433. </frameset>
  434.  
  435. </html>